package com.hsj;


public class _12_ChainRespPattern {
}


abstract class Handler {
    protected Handler nextHandler;

    public void setNextHandler(Handler handler) {
        this.nextHandler = nextHandler;
    }

    public abstract void process(Integer info);
}

class handleAB extends Handler {
    @Override
    public void process(Integer info) {
        if (info % 3 == 0 & info % 5 == 0)
            System.out.println("AB");
        else
            nextHandler.process(info);
    }
}

class HandleAC extends Handler {

    @Override
    public void process(Integer info) {
        if (info % 3 == 0 & info % 7 == 0)
            System.out.println("AC");
        else
            nextHandler.process(info);
    }
}